<template>
	<view>
		<view class="index-top"></view>
			<view style="position: relative;z-index: 1;" class="dis-flex-column wd100">
				<view class="ml15 mr15 index-box-shadow mt15">
					<u-swiper height="320" :list="bannerList" bgColor="#00000000" radius="10" :circular="true"></u-swiper>
				</view>
				<view class="dis-flex flex-align-center mt15">
					<!-- <view class="wd20 dis-flex-column flex-align-center" @tap="goContract(1)">
						<u-image src="/static/images/contract01.png" width="95" height="95"/>
						<view class="fs14 mt5 c-333">待生成</view>
					</view> -->
					<view class="wd50 dis-flex-column flex-align-center" @tap="goContract(0)">
						<u-image src="/static/images/contract02.png" width="95" height="95"/>
						<view class="fs14 mt5 c-333">待签约</view>
					</view>
					<view class="wd50 dis-flex-column flex-align-center" @tap="goContract(1)">
						<u-image src="/static/images/contract03.png" width="90" height="90"/>
						<view class="fs14 mt5 c-333">已签约</view>
					</view>
					<!-- <view class="wd20 dis-flex-column flex-align-center" @tap="goContract(4)">
						<u-image src="/static/images/contract04.png" width="90" height="90"/>
						<view class="fs14 mt5 c-333">已过期</view>
					</view>
					<view class="wd20 dis-flex-column flex-align-center" @tap="goContract(5)">
						<u-image src="/static/images/contract05.png" width="90" height="90"/>
						<view class="fs14 mt5 c-333">已作废</view>
					</view> -->
				</view>
				
				<view class="wd100">
					<view class="pl15 mt15">
						<view class="h2Title">当前持有的合同份数</view>
					</view>
					
					<view class="dis-flex flex-align-center flex-between mt10 px15">
						<view style="width: 330rpx;background: linear-gradient(#111, #f8f8f8);" class=" dis-flex-column flex-center py30 br10">
							<view class="fs15 c-fff fwb">{{waitNums}} 份</view>
							<view class="fs16 c-fff mt5">未签合同</view>
							<view class="fs12 c-666 mt5 px10">未签合同是指签署人(不包含发件方)中未签署的合同</view>
						</view>
						<view style="width: 330rpx;background: linear-gradient(#19be6b, #f8f8f8);" class=" dis-flex-column flex-center py30 br10">
							<view class="fs15 c-fff fwb">{{afterNums}} 份</view>
							<view class="fs16 c-fff mt5">已签合同</view>
							<view class="fs12 c-666 mt5 px10">已签合同是指签署人(不包含发件方)中已签署的合同</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	export default {
		computed:{
			...mapState(['refreshOrder']),
		},
		data() {
			return {
				bannerList:[],
				waitNums: 0,
				afterNums: 0,
			}
		},
		
		watch:{
			refreshOrder(val,old){
				this.UrlGetMyCount(2);
				this.UrlGetMyCount(3);
			}
		},
		
		onLoad(option) {
			this.getBanner();
			this.UrlGetMyCount(2);
			this.UrlGetMyCount(3);
		},
			
		onPullDownRefresh() {
			this.UrlGetMyCount(2);
			this.UrlGetMyCount(3);
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1500);
		},
			
		methods: {
			
			goContract(index){
				this.$api.openWindow('/pages/center/contract?index='+index);
			},
			
			getBanner(){
				this.$http.get(this.$config.UrlGetBanner, {
				}).then((res) => {
					this.bannerList = res?.data.map(x => {
						return this.$store.state.host + x
					})
				})
			},
			
			UrlGetMyCount(status){
				this.$http.post(this.$config.UrlGetMyCount, {status
				}, {
					header: {
						'content-type': 'application/json'
					}
				}).then((res) => {
					if (status == 2) {
						this.waitNums = res.data || 0
					} else if (status == 3) {
						this.afterNums = res.data || 0
					}
				})
			}
		}
	}
</script>

<style>
	.h2Title {
		padding-left: 30rpx;
		font-weight: 600;
		font-size: 32rpx;
		position: relative;
		&::before {
			content: '';
			display: block;
			width: 8rpx;
			height: 100%;
			background-color: #5B769F;
			position: absolute;
			left: 0;
			top: 0;
			border-radius: 2rpx;
		}
	}
	.index-box-shadow {
		box-shadow: 0rpx 5rpx 20rpx #d9d9d9, 5rpx 0rpx 20rpx #d9d9d9;
	}
</style>
